//
//  SendIFAPPDefault.m
//  LaoShan
//
//  Created by sendInfo on 2014-01-09.
//  Copyright (c) 2014年 dongMac. All rights reserved.
//

#import "SendIFAPPDefault.h"

@interface SendIFAPPDefault()
@property (nonatomic,strong)NSUserDefaults *defaults;
@end


@implementation SendIFAPPDefault
@synthesize defaults = _defaults;

+ (SendIFAPPDefault *)shareAppDefault{
    static id _sharedObj = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _sharedObj = [[SendIFAPPDefault alloc] initDefaults];
    });
    return _sharedObj;
}

- (id)initDefaults{
    
    self = [super init];
    if (self) {
        _defaults = [NSUserDefaults standardUserDefaults];
        [self registerSettings];
    }
    return self;
    
    
}
//程序启动时导入配置文件

- (void)registerSettings{
    
    NSString *settingsPath = [[NSBundle mainBundle] pathForResource:@"SendIFAPPDefault" ofType:@"plist"];
    NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:settingsPath];
    [self.defaults registerDefaults:dic];
    
}
#pragma mark -
- (void)setIsFirstLanuch:(NSString *)isFirst{
    
    [self.defaults setObject:isFirst forKey:IS_FIRSTLANUCH];
    [self.defaults synchronize];

}
- (NSString *)isFirstLanuch{
    
    return [self.defaults stringForKey:IS_FIRSTLANUCH];

}

#pragma mark -
- (void)setCurrentUserID:(NSString *)userNum{
    
    [self.defaults setObject:userNum forKey:CURRENT_USER_ID];
    [self.defaults synchronize];

}
- (NSString *)currentUserID{
    
    return [self.defaults stringForKey:CURRENT_USER_ID];

}
#pragma mark -
//登录状态
- (void)setLoginState:(NSString *)state{
    
    [self.defaults setObject:state forKey:LOGIN_STATE];
    [self.defaults synchronize];

}
- (NSString *)loginState{
    return [self.defaults stringForKey:LOGIN_STATE];
}
#pragma mark -
- (void)setLoginName:(NSString *)name{
    
    [self.defaults setObject:name forKey:LOGIN_NAME];
    [self.defaults synchronize];

}
- (NSString *)loginName{
    return [self.defaults stringForKey:LOGIN_NAME];

}
- (void)setUnique:(NSString *)que{

    [self.defaults setObject:que forKey:UNIQUE_Pizza];
    [self.defaults synchronize];
}
- (NSString *)unique{

     return [self.defaults stringForKey:UNIQUE_Pizza];
}
- (void)setIsMainHome:(NSString *)home{

    [self.defaults setObject:home forKey:ISMAINHOME];
    [self.defaults synchronize];
}
- (NSString *)isMainHome{
return [self.defaults stringForKey:ISMAINHOME];
}


- (void)setMobile:(NSString *)phone
{

    [self.defaults setObject:phone forKey:Mobile];
    [self.defaults synchronize];
}
- (NSString *)mobile
{

    return [self.defaults stringForKey:Mobile];
}

- (void)setUserToken:(NSString *)token
{

    [self.defaults setObject:token forKey:TOKEN_USER];
    [self.defaults synchronize];
}
- (NSString *)userToken
{
 return [self.defaults stringForKey:TOKEN_USER];
}

- (void)setUserImgurl:(NSString *)imgurl
{

    [self.defaults setObject:imgurl forKey:IMGURL_USER];
    [self.defaults synchronize];
}
- (NSString *)userImgurl
{

    return [self.defaults stringForKey:IMGURL_USER];
}
- (void)setIsBoxAccount:(NSString *)acc
{

    [self.defaults setObject:acc forKey:IS_REGISTER_BOXACCOUNT];
    [self.defaults synchronize];
}
- (NSString *)isBoxAccount
{

    return [self.defaults stringForKey:IS_REGISTER_BOXACCOUNT];
}

- (void)setSelectedGoodsShopID:(NSString *)shopid
{

    [self.defaults setObject:shopid forKey:SHOPID];
    [self.defaults synchronize];
}
- (NSString *)selectedGoodsShopID
{

    return  [self.defaults stringForKey:SHOPID];
}
@end
